<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<title>Document</title>

</head>

<body>
	<script type="text/javascript">
		// 编写通用方法,把URL参数解析为一个对象，如：var url = “http://witmax.cn/index.php?key0=0&key1=1&key2=2″;    返回数据{key0: "0", key1: "1", key2: "2"}  
		var url = 'http://witmax.cn/index.php?key0=0&key1=1&key2=2'
		var str = url.split('?')
		console.log(str);
		var str1 = str[1].split('&')
		let obj = {}
		str1.forEach(item => {
			obj = {
				...obj, ...{
					[item.split("=")[0]]: item.split("=")[1]
				}
			}
		})
		console.log(obj);

	</script>
</body>

</html>